using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

namespace LS.UI
{
    public static class UIElementsExtension
    {

#if UNITY_2023_1_OR_NEWER

        public static void AddChild(this ToggleButtonGroup toggleButtonGroup, VisualElement child)
        {
            if (toggleButtonGroup.contentContainer == toggleButtonGroup)
                toggleButtonGroup[0].Add(child);
            else
                toggleButtonGroup.Add(child);
        }

        public static void RemoveChild(this ToggleButtonGroup toggleButtonGroup, VisualElement child)
        {
            if (toggleButtonGroup.contentContainer == toggleButtonGroup)
                toggleButtonGroup[0].Remove(child);
            else
                toggleButtonGroup.Remove(child);
        }

        public static void ClearChildren(this ToggleButtonGroup toggleButtonGroup)
        {
            if (toggleButtonGroup.contentContainer == toggleButtonGroup)
                toggleButtonGroup[0].Clear();
            else
                toggleButtonGroup.Clear();
        }

#endif

    }
}
